package com.juzipi.demo.controller;


import com.juzipi.demo.pojo.User;
import com.juzipi.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("page")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping
    public Long getUser(
            @RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
            @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize
            ){
        Long s = userService.queryUser(pageNum, pageSize);
        System.out.println(s);
        return s;
    }

    @PostMapping("add")
    public String addUser(@RequestBody User user){
        userService.createUser(user);
        return "SUCCESS";
    }

}
